package com.xxxx.portal.service.impl;

import com.xxxx.common.utils.CookieUtil;
import com.xxxx.portal.service.ICookieService;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Service
public class CookieService implements ICookieService {

    @Override
    public boolean setCookie(HttpServletRequest request, HttpServletResponse response, String ticket) {

        try {
            CookieUtil.setCookie(request,response,"userTicket",ticket);
            return  true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public String getCookie(HttpServletRequest request) {
        return CookieUtil.getCookieValue(request,"userTicket");
    }

    @Override
    public boolean deleteCookie(HttpServletRequest request, HttpServletResponse response) {
        try {
            CookieUtil.deleteCookie(request,response,"userTicket");
            return  true;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
    }

}
